//
//  CBJBaseNavController.swift
//  Weibo
//
//  Created by 崔健 on 16/5/20.
//  Copyright © 2016年 cbj. All rights reserved.
//

import UIKit
//import AFNetworking

class CBJBaseNavController: UINavigationController,UIGestureRecognizerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()

        interactivePopGestureRecognizer?.delegate = self
        
    }
    
    
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        
        
        if childViewControllers.count > 0 {
            
            if childViewControllers.count == 1 {
                
                viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: "navigationbar_back_withtext", title: topViewController!.navigationItem.title ?? "返回", target: self, action: #selector(popNavVc))

            }else{
            
                viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: "navigationbar_back_withtext", title: "返回", target: self, action: #selector(popNavVc))
            }
            
        }
        
        super.pushViewController(viewController, animated: animated)
    }
    

    
    
    func popNavVc() {
        
        popViewControllerAnimated(true);
    }
    
    func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
        
        return childViewControllers.count > 1
    }
    
}
